package com.sqly.doc.menu.ycf;

import android.content.Context;
import android.content.Intent;
import android.graphics.Bitmap;
import android.graphics.BitmapFactory;
import android.os.Environment;
import android.text.Editable;
import android.text.TextWatcher;
import android.view.View;
import android.widget.CheckBox;
import android.widget.CompoundButton;
import android.widget.EditText;
import android.widget.ImageView;
import android.widget.LinearLayout;
import android.widget.RadioGroup;
import android.widget.TextView;

import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONObject;
import com.ihidea.multilinechooselib.MultiLineChooseLayout;
import com.loopj.android.http.AsyncHttpResponseHandler;
import com.loopj.android.http.RequestParams;
import com.nostra13.universalimageloader.core.ImageLoader;
import com.sqly.doc.R;
import com.sqly.doc.base.MyBaseActivity;
import com.sqly.doc.menu.camera.CameraChoose;
import com.sqly.doc.menu.fjh.fjhdycrhsf;
import com.sqly.doc.menu.tnb.tnb;
import com.sqly.doc.pojo.JuMin;
import com.sqly.doc.pojo.RetMsg;
import com.sqly.doc.pojo.YcfDyccqjc;
import com.sqly.doc.user.choose_user;
import com.sqly.doc.util.BinderUtil;
import com.sqly.doc.util.CreateBitmap;
import com.sqly.doc.util.DateConvert;
import com.sqly.doc.util.HttpUrl;
import com.sqly.doc.util.MyToastUtil;
import com.sqly.doc.util.NetWorkUtils;
import com.sqly.doc.util.SharedPreferencesUtils;
import com.sqly.doc.util.SweetAlertDialogUtil;
import com.sqly.doc.util.Url;
import com.sqly.doc.util.UserClient;
import com.sqly.doc.util.WriteActivity;
import com.sqly.doc.view.CustomDatePicker;
import com.sqly.doc.view.StringUtils;

import java.io.File;
import java.io.FileNotFoundException;
import java.text.SimpleDateFormat;
import java.util.ArrayList;
import java.util.Date;
import java.util.List;
import java.util.Locale;

import cz.msebera.android.httpclient.Header;

//import cn.pedant.SweetAlert.SweetAlertDialog;


/**
 */

public class ycf_1 extends MyBaseActivity {
    private CustomDatePicker customDatePicker;
    Context con = ycf_1.this;
    JuMin j;
    //标题
    TextView title, uname;
    LinearLayout back;
    //
    TextView tbrq;
    EditText yz, yfnl, zfxm, zfnl, yunci, ydfm, pgc, mcyjdes, ycq, jwsqt, jzsqt, grsqt, fksssdes, ydfmwqt, ydqjdqt;
    CheckBox mcyj;
    MultiLineChooseLayout jws, jzs, grs, ydfmw, ydqjd, bjzd;//症状
    private List<String> jwsdata = new ArrayList<>();
    private List<String> jzsdata = new ArrayList<>();
    private List<String> grsdata = new ArrayList<>();
    private List<String> ydfmwdata = new ArrayList<>();
    private List<String> ydqjddata = new ArrayList<>();
    private List<String> bjzddata = new ArrayList<>();
    //孕产史
    EditText zrlc, rglc, st, sc, xsesw, cseqx, sg, tz, tzl, xy1, xy2;
    //听诊
    RadioGroup xz, fb, wy, yd, gj, zg, fj, fksss;
    //血型
    RadioGroup xx, xxrh;

    EditText xzqt, fbqt, wyqt, ydqt, gjqt, zgqt, fjqt;
    //辅助检查
    EditText xhdbz, bxbjsz, xxbjsz, xcgqt, ndb, nt, ndt, nqx, ncgqt, xt, xqgbzam, xqgczam, bdb, zdhs, jhdhs, xqjg, xns;
    EditText yxggybmky, yxgybmkt, yxgyeky, yxgyekt, yxgyhxkt, bc, yxgywxqt, ztpgyc, bjzdqt;
    RadioGroup mdxqxsy, hivktcy, ztpg, jcqk;
    //转诊
    EditText zzyy, jgjkb, lxr, lxdh;
    RadioGroup zzjg, zz;
    String zzjgs = "";
    TextView xcsfrq;

    String JKDAH = "";
    TextView xm;

    ///孕产妇
    YcfDyccqjc obj;//检查信息存储

    ImageView sfysqm, brqm, xcqm;
    String sfysqmpic = "", brqmpic = "",xcqmpic ="";

    boolean isadd = false;//是否是新添加
    String url = "";

    ImageView xcpaizhao;
    TextView pz_record_id,jmqm_record_id, ysqm_record_id;
    boolean pzChange = false;

    @Override
    protected void initUI() {
        setContentView(R.layout.ycf1);
        if (NetWorkUtils.isNetworkConnected(con)) {
            if (getIntent().getStringExtra("type").equals("edit")) {
                obj = (YcfDyccqjc) getIntent().getExtras().getSerializable("b");
                init();
                if(!StringUtils.isEmpty(obj.getImg())){
                    //ImageLoader.getInstance().displayImage(Url.img_url()+obj.getImg(),brqm);
                    ImageLoader.getInstance().displayImage(Url.newStaticurl(SharedPreferencesUtils.getParam(con, "token", "").toString(), "2" ,obj.getImg()),brqm);
                }
                if(!StringUtils.isEmpty(obj.getImg1())){
                    //ImageLoader.getInstance().displayImage(Url.img_url()+obj.getImg1(),sfysqm);
                    ImageLoader.getInstance().displayImage(Url.newStaticurl(SharedPreferencesUtils.getParam(con, "token", "").toString(), "2" ,obj.getImg1()),sfysqm);
                }
                if(!StringUtils.isEmpty(obj.getImg2())){
                    //ImageLoader.getInstance().displayImage(Url.img_url()+obj.getImg2(),xcqm);
                    ImageLoader.getInstance().displayImage(Url.newStaticurl(SharedPreferencesUtils.getParam(con, "token", "").toString(), "2" ,obj.getImg2()),xcqm);
                }
                xm.setClickable(false);
                yunci.setFocusable(false);
                yunci.setFocusableInTouchMode(false);
                //brqm.setClickable(false);
                //sfysqm.setClickable(false);
            }else {
                obj = new YcfDyccqjc();
                init();
            }

        }
    }

    @Override
    protected void onActivityResult(int requestCode, int resultCode, Intent data) {
        super.onActivityResult(requestCode, resultCode, data);
        if (data == null) {

        } else {
            if (requestCode == 1) {
                j = (JuMin) data.getExtras().getSerializable("j");
                getObject();
            }else if (requestCode == 8) {
                String record_id = (String) data.getExtras().getString("record_id");
                ysqm_record_id.setText(record_id);
                byte[] bis = data.getByteArrayExtra("bitmap");
                Bitmap bmp = BitmapFactory.decodeByteArray(bis, 0, bis.length);
                Bitmap bb = CreateBitmap.zoomImg(bmp, 1, 1);
                sfysqm.setImageBitmap(bb);
                sfysqmpic = CreateBitmap.saveMyBitmap(bb);
            }else if (requestCode == 9) {
                String record_id = (String) data.getExtras().getString("record_id");
                jmqm_record_id.setText(record_id);
                byte[] bis = data.getByteArrayExtra("bitmap");
                Bitmap bmp = BitmapFactory.decodeByteArray(bis, 0, bis.length);
                Bitmap bb = CreateBitmap.zoomImg(bmp, 1, 1);
                brqm.setImageBitmap(bb);
                brqmpic = CreateBitmap.saveMyBitmap(bb);
            }else if(requestCode == 119){
                String img_record_id = (String) data.getExtras().getString("img_record_id");
                pz_record_id.setText(img_record_id);
                pzChange = true;
                byte[] bis = data.getByteArrayExtra("bitmap");
                Bitmap bmp = BitmapFactory.decodeByteArray(bis, 0, bis.length);
                Bitmap bb = CreateBitmap.zoomImg(bmp, 1, 1);
                xcqm.setImageBitmap(bb);
            }
        }
    }

    public void init() {
        back = (LinearLayout) findViewById(R.id.back);
        back.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View view) {
                if(pzChange){
                   SweetAlertDialogUtil.WarningDialogHaveCancelAndConfirm(con,"你确认不保存数据更新吗？","现场拍照已经采集，请注意点击“保存”","确定", "返回");
                }else {
                    finish();
                }
            }
        });
        yunci = (EditText) findViewById(R.id.yc);
        if (obj != null && !StringUtils.isEmpty(obj.getYUNCI())) {
            yunci.setText(obj.getYUNCI());
        }
        yunci.addTextChangedListener(new TextWatcher() {
            @Override
            public void beforeTextChanged(CharSequence s, int start, int count, int after) {

            }

            @Override
            public void onTextChanged(CharSequence s, int start, int before, int count) {

            }

            @Override
            public void afterTextChanged(Editable s) {
                obj.setJKDAH("");
                obj.setMCYJ("");
                obj.setXINGMING("");
                obj.setCARDNUM("");
                mcyjdes.setText("");
                JKDAH = "";
                xm.setText("");
            }
        });
        //转诊
        zzyy = (EditText) findViewById(R.id.zz_yy);
        xm = (TextView) findViewById(R.id.XINGMING);
        if (obj != null && !StringUtils.isEmpty(obj.getXINGMING())) {
            xm.setText(obj.getXINGMING());
        } else {
            xm.setOnClickListener(new View.OnClickListener() {
                @Override
                public void onClick(View v) {
                    if(null != yunci && StringUtils.isEmpty(yunci.getText().toString())){
                        MyToastUtil.ShowToast(con, "请先输入孕次");
                    }else if(!BinderUtil.isZzs(yunci.getText().toString())){
                        MyToastUtil.ShowToast(con, "孕次必须为正整数");
                    }else {
                        startActivityForResult(new Intent(con, choose_user.class).putExtra("cname", "ycf_1.class"),1);
                    }
                }
            });
        }

        if (obj != null && !StringUtils.isEmpty(obj.getZZYY())) {
            zzyy.setText(obj.getZZYY());
        }

        jgjkb = (EditText) findViewById(R.id.zzjg);
        if (obj != null && !StringUtils.isEmpty(obj.getZZJG())) {
            jgjkb.setText(obj.getZZJG());
        }

        lxr = (EditText) findViewById(R.id.zz_lxr);
        if (obj != null && !StringUtils.isEmpty(obj.getZZLXR())) {
            lxr.setText(obj.getZZLXR());
        }

        lxdh = (EditText) findViewById(R.id.zz_lxfs);
        if (obj != null && !StringUtils.isEmpty(obj.getZZLXFS())) {
            lxdh.setText(obj.getZZLXFS());
        }

        zzjg = (RadioGroup) findViewById(R.id.jg);
        if (obj != null && !StringUtils.isEmpty(obj.getZZJG())) {
            switch (Integer.parseInt(obj.getZZJG())) {
                case 1:
                    zzjg.check(R.id.dw);
                    break;
                case 2:
                    zzjg.check(R.id.wdw);
                    break;
            }
        }

        zzjg.setOnCheckedChangeListener(new RadioGroup.OnCheckedChangeListener() {
            @Override
            public void onCheckedChanged(RadioGroup group, int checkedId) {
                if (checkedId == R.id.dw)
                    obj.setZZJG("1");
                else
                    obj.setZZJG("2");
            }
        });

        zz = (RadioGroup) findViewById(R.id.zz);
        if (obj != null && !StringUtils.isEmpty(obj.getSFZZ())) {
            switch (Integer.parseInt(obj.getSFZZ())) {
                case 1:
                    zz.check(R.id.zz_wu);
                    break;
                case 2:
                    zz.check(R.id.zz_you);
                    break;
            }
        }

        zz.setOnCheckedChangeListener(new RadioGroup.OnCheckedChangeListener() {
            @Override
            public void onCheckedChanged(RadioGroup group, int checkedId) {
                if (checkedId == R.id.zz_wu) {
                    zzyy.setEnabled(false);
                    jgjkb.setEnabled(false);
                    lxr.setEnabled(false);
                    lxdh.setEnabled(false);
                    obj.setSFZZ("1");
                } else {
                    zzyy.setEnabled(true);
                    jgjkb.setEnabled(true);
                    lxr.setEnabled(true);
                    lxdh.setEnabled(true);
                    obj.setSFZZ("2");
                }
            }
        });
        xcsfrq = (TextView) findViewById(R.id.xcsfrq);
        if (obj != null && !StringUtils.isEmpty(obj.getXCSFRQ())) {
            xcsfrq.setText(DateConvert.dateToString(DateConvert.toDate(obj.getXCSFRQ(), DateConvert.YMD), DateConvert.YMD)+"");
        }
        xcsfrq.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View view) {
                SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm", Locale.CHINA);
                customDatePicker = new CustomDatePicker(con, new CustomDatePicker.ResultHandler() {
                    @Override
                    public void handle(String time) { // 回调接口，获得选中的时间
                        xcsfrq.setText(time.split(" ")[0]);
                    }
                }, DateConvert.getCustomDatePickerStartRq(), DateConvert.getCustomDatePickerEndRq()); // 初始化日期格式请用：yyyy-MM-dd HH:mm，否则不能正常运行
                customDatePicker.showSpecificTime(false); // 不显示时和分
                customDatePicker.setIsLoop(false); // 不允许循环滚动
                customDatePicker.show(DateConvert.getCustomDatePickerNowRq());
            }
        });
        //医生签名
        sfysqm = (ImageView) findViewById(R.id.sfysqm);
        if (obj != null && !StringUtils.isEmpty(obj.getSfysqm())) {
            sfysqmpic = obj.getSfysqm();
            sfysqm.setImageBitmap(BitmapFactory.decodeFile(Environment.getExternalStorageDirectory() + "/" + sfysqmpic + ".jpg"));
        }
        sfysqm.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                startActivityForResult(new Intent(con, WriteActivity.class)
                        .putExtra("cardnum", obj.getCARDNUM())
                        .putExtra("tabId", null==obj.getSFJLH()||"".equals(obj.getSFJLH()) ? "noid" : obj.getSFJLH())
                        .putExtra("tabType", "ycfdyccqsf")
                        .putExtra("imageType", "img1")
                        .putExtra("class", "ycf_1.class"), 8);
            }
        });
        brqm = (ImageView) findViewById(R.id.brqm);
        if (obj != null && !StringUtils.isEmpty(obj.getBrqm())) {
            brqmpic = obj.getBrqm();
            brqm.setImageBitmap(BitmapFactory.decodeFile(Environment.getExternalStorageDirectory() + "/" + brqmpic + ".jpg"));
        }
        brqm.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                startActivityForResult(new Intent(con, WriteActivity.class)
                        .putExtra("cardnum", obj.getCARDNUM())
                        .putExtra("tabId", null==obj.getSFJLH()||"".equals(obj.getSFJLH()) ? "noid" : obj.getSFJLH())
                        .putExtra("tabType", "ycfdyccqsf")
                        .putExtra("imageType", "img")
                        .putExtra("class","ycf_1.class"), 9);
            }
        });
        xcqm = (ImageView) findViewById(R.id.xcqm);
        if (obj != null && !StringUtils.isEmpty(obj.getXcqm())) {
            xcqmpic = obj.getXcqm();
            xcqm.setImageBitmap(BitmapFactory.decodeFile(Environment.getExternalStorageDirectory() + "/" + xcqmpic + ".jpg"));
        }
        xcqm.setOnClickListener(new CustomerListener());
        //现场拍照
        xcpaizhao = (ImageView) findViewById(R.id.xcpaizhao);
        xcpaizhao.setOnClickListener(new CustomerListener());
        //现场拍照照片id
        pz_record_id = (TextView) findViewById(R.id.pz_record_id);
        if(obj != null && !StringUtils.isEmpty(obj.getImg2())) {
            //fjhdycrhsf/D24E75C5BB5E417EBE65494CA09BF399.jpg
            String[] img2Arr =obj.getImg2().split("/");
            if(null !=img2Arr && img2Arr.length>1){
                pz_record_id.setText(img2Arr[1]);
            }
        }
        jmqm_record_id= (TextView) findViewById(R.id.jmqm_record_id);
        if(obj != null && !StringUtils.isEmpty(obj.getImg())) {
            String[] img2Arr =obj.getImg().split("/");
            if(null !=img2Arr && img2Arr.length>1){
                jmqm_record_id.setText(img2Arr[1]);
            }
        }
        ysqm_record_id= (TextView) findViewById(R.id.ysqm_record_id);
        if(obj != null && !StringUtils.isEmpty(obj.getImg1())) {
            //fjhdycrhsf/D24E75C5BB5E417EBE65494CA09BF399.jpg
            String[] img2Arr =obj.getImg1().split("/");
            if(null !=img2Arr && img2Arr.length>1){
                ysqm_record_id.setText(img2Arr[1]);
            }
        }

        title = (TextView) findViewById(R.id.title);
        uname = (TextView) findViewById(R.id.uname);
        title.setText("第1次产前检查服务");
        uname.setText("保存");
        uname.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View view) {
                if(null != yunci && StringUtils.isEmpty(yunci.getText().toString())){
                    MyToastUtil.ShowToast(con, "请输入孕次");
                }else if(!BinderUtil.isZzs(yunci.getText().toString())){
                    MyToastUtil.ShowToast(con, "孕次必须为正整数");
                }else if(null == xm.getText().toString() || "".equals(xm.getText().toString())){
                    SweetAlertDialogUtil.WarningDialog(con, "提示", "姓名不能为空");
                }else if ("1".equals(SharedPreferencesUtils.getParam(con, "ysqm", "0").toString()) && ysqm_record_id.getText().toString().equals("noid")) {
                    SweetAlertDialogUtil.WarningDialog(con, "提示", "随访医生签名不能为空");
                }else if ("1".equals(SharedPreferencesUtils.getParam(con, "jmqm", "0").toString()) && jmqm_record_id.getText().toString().equals("noid")) {
                    SweetAlertDialogUtil.WarningDialog(con, "提示", "家属或本人签名不能为空");
                }else if ("1".equals(SharedPreferencesUtils.getParam(con, "xcpz", "0").toString()) && pz_record_id.getText().toString().equals("noid")) {
                    SweetAlertDialogUtil.WarningDialog(con, "提示", "现场拍照不能为空");
                }else if(null == tbrq.getText().toString() || "".equals(tbrq.getText().toString())){
                    SweetAlertDialogUtil.WarningDialog(con, "提示", "填表日期不能为空");
                } else if(null == xcsfrq.getText().toString() || "".equals(xcsfrq.getText().toString())){
                    SweetAlertDialogUtil.WarningDialog(con, "提示", "下次随访日期不能为空");
                }else {
                    if (obj == null) {
                        obj = new YcfDyccqjc();
                    }
                    obj.setSFRQ(tbrq.getText().toString());
                    obj.setYUNZHOU(yz.getText().toString());
                    obj.setYFNL(yfnl.getText().toString());
                    obj.setZFXM(zfxm.getText().toString());
                    obj.setZFNL(zfnl.getText().toString());
                    obj.setYUNCI(yunci.getText().toString());
                    obj.setCHANCI_YD(ydfm.getText().toString());
                    obj.setCHANCI_PG(pgc.getText().toString());
                    if (mcyj.isChecked())
                        obj.setMCYJ("不详");
                    else
                        obj.setMCYJ(mcyjdes.getText().toString());
                    obj.setYCQ(ycq.getText().toString());
                    ArrayList<Integer> jwslist = jws.getAllItemSelectedIndex();
                    String jwss = "";
                    for (int i = 0; i < jwslist.size(); i++) {
                        if (i == 0)
                            jwss = jwslist.get(i) + "";
                        else
                            jwss = jwss + "," + jwslist.get(i);
                    }
                    obj.setJWS(jwss);
                    obj.setJWSQT(jwsqt.getText().toString());
                    ArrayList<Integer> jzslist = jzs.getAllItemSelectedIndex();
                    String jzss = "";
                    for (int i = 0; i < jzslist.size(); i++) {
                        if (i == 0)
                            jzss = jzslist.get(i) + "";
                        else
                            jzss = jzss + "," + jzslist.get(i);
                    }
                    obj.setJZS(jzss);

                    obj.setJZSQT(jzsqt.getText().toString());
                    ArrayList<Integer> grslist = jzs.getAllItemSelectedIndex();
                    String grss = "";
                    for (int i = 0; i < grslist.size(); i++) {
                        if (i == 0)
                            grss = grslist.get(i) + "";
                        else
                            grss = grss + "," + grslist.get(i);
                    }
                    obj.setGRS(grss);

                    obj.setGRSQT(grsqt.getText().toString());
                    obj.setFKSSSQT(fksssdes.getText().toString());
                    obj.setYCSLC(zrlc.getText().toString());
                    obj.setYCSLCRG(rglc.getText().toString());
                    obj.setYCSST(st.getText().toString());
                    obj.setYCSXSESW(xsesw.getText().toString());
                    obj.setYCSCSQXE(cseqx.getText().toString());
                    obj.setSHENGAO(sg.getText().toString());
                    obj.setTIZHONG(tz.getText().toString());
                    obj.setBMI(tzl.getText().toString());
                    obj.setXUEYA1(xy1.getText().toString());
                    obj.setXUEYA2(xy2.getText().toString());
                    obj.setXZYC(xzqt.getText().toString());
                    obj.setFBYC(fbqt.getText().toString());
                    obj.setWYYC(wyqt.getText().toString());
                    obj.setYDYC(ydqt.getText().toString());
                    obj.setGJYC(gjqt.getText().toString());
                    obj.setZGYC(zgqt.getText().toString());
                    obj.setFJYC(fjqt.getText().toString());
                    obj.setXHDBZ(xhdbz.getText().toString());
                    obj.setBXBJSZ(bxbjsz.getText().toString());
                    obj.setXXBJSZ(xxbjsz.getText().toString());
                    obj.setXCGQT(xcgqt.getText().toString());
                    obj.setNDB(ndb.getText().toString());
                    obj.setNT(nt.getText().toString());
                    obj.setNTT(ndt.getText().toString());
                    obj.setNQX(nqx.getText().toString());
                    obj.setNCGQT(ncgqt.getText().toString());

                    obj.setXT(xt.getText().toString());
                    obj.setXQGBZAM(xqgbzam.getText().toString());
                    obj.setXQGCZAM(xqgczam.getText().toString());
                    obj.setBDB(bdb.getText().toString());
                    obj.setZDHS(zdhs.getText().toString());
                    obj.setJHDHS(jhdhs.getText().toString());
                    obj.setXQJG(xqjg.getText().toString());
                    ArrayList<Integer> ydfmwlist = ydfmw.getAllItemSelectedIndex();
                    String ydfmws = "";
                    for (int i = 0; i < ydfmwlist.size(); i++) {
                        if (i == 0)
                            ydfmws = ydfmwlist.get(i) + "";
                        else
                            ydfmws = ydfmws + "," + ydfmwlist.get(i);
                    }
                    obj.setYDFMW(ydfmws);
                    obj.setYDFMWQT(ydfmwqt.getText().toString());
                    ArrayList<Integer> ydqjdlist = ydfmw.getAllItemSelectedIndex();
                    String ydqjds = "";
                    for (int i = 0; i < ydqjdlist.size(); i++) {
                        if (i == 0)
                            ydqjds = ydqjdlist.get(i) + "";
                        else
                            ydqjds = ydqjds + "," + ydqjdlist.get(i);
                    }
                    obj.setYDQJD(ydqjds);

                    obj.setYXGYBMKY(yxggybmky.getText().toString());
                    obj.setYXGYBMKT(yxgybmkt.getText().toString());
                    obj.setYXGYEKY(yxgyeky.getText().toString());
                    obj.setYXGYEKT(yxgyekt.getText().toString());
                    obj.setYXGYHXKT(yxgyhxkt.getText().toString());
                    obj.setBCHAO(bc.getText().toString());
                    obj.setFZJCQT(yxgywxqt.getText().toString());

                    ArrayList<Integer> zdlist = ydfmw.getAllItemSelectedIndex();
                    String bjzds = "";
                    for (int i = 0; i < zdlist.size(); i++) {
                        if (i == 0)
                            bjzds = zdlist.get(i) + "";
                        else
                            bjzds = bjzds + "," + zdlist.get(i);
                    }
                    obj.setBJZD(bjzds);
                    obj.setBJZDQT(bjzdqt.getText().toString());
                    obj.setZZYY(zzyy.getText().toString());
                    obj.setZZJGJKS(jgjkb.getText().toString());
                    obj.setZZLXR(lxr.getText().toString());
                    obj.setZZLXFS(lxdh.getText().toString());
                    obj.setXCSFRQ(xcsfrq.getText().toString());

                    if (NetWorkUtils.isNetworkConnected(con)) {  ///网络连接
                        RequestParams ps = new RequestParams();
                        ps.add("entity.SFRQ", obj.getSFRQ());
                        ps.add("entity.YUNZHOU", obj.getYUNZHOU());
                        ps.add("entity.YFNL", obj.getYFNL());
                        ps.add("entity.ZFXM", obj.getZFXM());
                        ps.add("entity.ZFNL", obj.getZFNL());
                        ps.add("entity.YUNCI", obj.getYUNCI());
                        ps.add("entity.CHANCI_YD", obj.getCHANCI_YD());
                        ps.add("entity.CHANCI_PG", obj.getCHANCI_PG());
                        ps.add("entity.MCYJ", obj.getMCYJ());
                        ps.add("entity.YCQ", obj.getYCQ());
                        ps.add("entity.JWS", obj.getJWS());
                        ps.add("entity.JZS", obj.getJZS());
                        ps.add("entity.GRS", obj.getGRS());
                        ps.add("entity.JWSQT", obj.getJWSQT());
                        ps.add("entity.JZSQT", obj.getJZSQT());
                        ps.add("entity.GRSQT", obj.getGRSQT());
                        ps.add("entity.FKSSS", obj.getFKSSS());
                        ps.add("entity.FKSSSQT", obj.getFKSSSQT());
                        ps.add("entity.YCSLC", obj.getYCSLC());
                        ps.add("entity.YCSLCRG", obj.getYCSLCRG());
                        ps.add("entity.YCSST", obj.getYCSST());
                        ps.add("entity.YCSSC", obj.getYCSSC());
                        ps.add("entity.YCSXSESW", obj.getYCSXSESW());
                        ps.add("entity.YCSCSQXE", obj.getYCSCSQXE());
                        ps.add("entity.SHENGAO", obj.getSHENGAO());
                        ps.add("entity.TIZHONG", obj.getTIZHONG());
                        ps.add("entity.BMI", obj.getBMI());
                        ps.add("entity.XUEYA1", obj.getXUEYA1());
                        ps.add("entity.XUEYA2", obj.getXUEYA2());
                        ps.add("entity.XINZANG", obj.getXINZANG());
                        ps.add("entity.XZYC", obj.getXZYC());
                        ps.add("entity.FEIBU", obj.getFEIBU());
                        ps.add("entity.FBYC", obj.getFBYC());
                        ps.add("entity.WAIYIN", obj.getWAIYIN());
                        ps.add("entity.WYYC", obj.getWYYC());
                        ps.add("entity.YINDAO", obj.getYINDAO());
                        ps.add("entity.YDYC", obj.getYDYC());
                        ps.add("entity.GONGJING", obj.getGONGJING());
                        ps.add("entity.GJYC", obj.getGJYC());
                        ps.add("entity.ZIGONG", obj.getZIGONG());
                        ps.add("entity.ZGYC", obj.getZGYC());
                        ps.add("entity.FUJIAN", obj.getFUJIAN());
                        ps.add("entity.FJYC", obj.getFJYC());
                        ps.add("entity.XHDBZ", obj.getXHDBZ());
                        ps.add("entity.BXBJSZ", obj.getBXBJSZ());
                        ps.add("entity.XXBJSZ", obj.getXXBJSZ());
                        ps.add("entity.XCGQT", obj.getXCGQT());
                        ps.add("entity.NDB", obj.getNDB());
                        ps.add("entity.NT", obj.getNT());
                        ps.add("entity.NTT", obj.getNTT());
                        ps.add("entity.NQX", obj.getNQX());
                        ps.add("entity.NCGQT", obj.getNCGQT());
                        ps.add("entity.XX", obj.getXX());
                        ps.add("entity.RH", obj.getRH());
                        ps.add("entity.XT", obj.getXT());
                        ps.add("entity.XQGBZAM", obj.getXQGBZAM());
                        ps.add("entity.XQGCZAM", obj.getXQGCZAM());
                        ps.add("entity.BDB", obj.getBDB());
                        ps.add("entity.ZDHS", obj.getZDHS());
                        ps.add("entity.JHDHS", obj.getJHDHS());
                        ps.add("entity.XQJG", obj.getXQJG());
                        ps.add("entity.XNSD", obj.getXNSD());
                        ps.add("entity.YDFMW", obj.getYDFMW());
                        ps.add("entity.YDQJD", obj.getYDQJD());
                        ps.add("entity.YXGYBMKY", obj.getYXGYBMKY());
                        ps.add("entity.YXGYBMKT", obj.getYXGYBMKT());
                        ps.add("entity.YXGYEKY", obj.getYXGYEKY());
                        ps.add("entity.YXGXEKT", obj.getYXGYEKT());
                        ps.add("entity.YXGYHXKT", obj.getYXGYHXKT());
                        ps.add("entity.MDXQXSY", obj.getMDXQXSY());
                        ps.add("entity.HIVKTJC", obj.getHIVKTJC());
                        ps.add("entity.BCHAO", obj.getBCHAO());
                        ps.add("entity.FZJCQT", obj.getFZJCQT());
                        ps.add("entity.ZTPG", obj.getZTPG());
                        ps.add("entity.BJZD", obj.getBJZD());
                        ps.add("entity.BJZDQT", obj.getBJZDQT());
                        ps.add("entity.JCQK", obj.getJCQK());
                        ps.add("entity.SFZZ", obj.getSFZZ());
                        ps.add("entity.ZZYY", obj.getZZYY());
                        ps.add("entity.ZZJGJKS", obj.getZZJGJKS());
                        ps.add("entity.ZZLXR", obj.getZZLXR());
                        ps.add("entity.ZZLXFS", obj.getZZLXFS());
                        ps.add("entity.ZZJG", obj.getZZJG());
                        ps.add("entity.XCSFRQ", obj.getXCSFRQ());
                        ps.add("entity.XINGMING", obj.getXINGMING());

                        if (isadd) {
                            ps.add("entity.JKDAH", JKDAH);
                            url = HttpUrl.SaveYcf1;
                        } else {
                            ps.add("entity.SFJLH", obj.getSFJLH());
                            ps.add("entity.JKDAH", obj.getJKDAH());
                            url = HttpUrl.EditYcf1;
                        }
                        ps.add("entity.CARDNUM", obj.getCARDNUM());
                        ps.add("token", SharedPreferencesUtils.getParam(con, "token", "").toString());
                        ps.add("type", "2");

                        ps.add("pz_record_id", pz_record_id.getText().toString());
                        ps.add("jmqm_record_id", jmqm_record_id.getText().toString());
                        ps.add("ysqm_record_id", jmqm_record_id.getText().toString());
                        ps.add("entity.UPDATETIME", obj.getUPDATETIME());
                        //ycf_1.super.ImageUploadOperate(sfysqmpic, brqmpic, ps);
                        UserClient.get(url, ps, new AsyncHttpResponseHandler() {
                            @Override
                            public void onSuccess(int statusCode, Header[] headers, byte[] response) {
                                String content = new String(response);
                                RetMsg ret = JSON.parseObject(content, RetMsg.class);
                                if (ret.getCode().equals("200")) {
                                    MyToastUtil.ShowToast(con, "成功");
                                }else{
                                    MyToastUtil.ShowToast(con, ret.getInfo());
                                }
                               finish();
                            }

                            @Override
                            public void onFailure(int statusCode, Header[] headers, byte[] errorResponse, Throwable e) {

                                MyToastUtil.ShowToast(con, "失败");
                            }
                        });
                    }
                }
            }
        });

        tbrq = (TextView) findViewById(R.id.tbrq);
        if (obj != null && !StringUtils.isEmpty(obj.getSFRQ())) {
            tbrq.setText(DateConvert.dateToString(DateConvert.toDate(obj.getSFRQ(), DateConvert.YMD), DateConvert.YMD)+"");
        }
        tbrq.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View view) {
                SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm", Locale.CHINA);
                String now = sdf.format(new Date());
                customDatePicker = new CustomDatePicker(con, new CustomDatePicker.ResultHandler() {
                    @Override
                    public void handle(String time) { // 回调接口，获得选中的时间
                        tbrq.setText(time.split(" ")[0]);
                    }
                }, "2010-01-01 00:00", now); // 初始化日期格式请用：yyyy-MM-dd HH:mm，否则不能正常运行
                customDatePicker.showSpecificTime(false); // 不显示时和分
                customDatePicker.setIsLoop(false); // 不允许循环滚动
                customDatePicker.show(now);
            }
        });
        yz = (EditText) findViewById(R.id.yz);
        if (obj != null && !StringUtils.isEmpty(obj.getYUNZHOU())) {
            yz.setText(obj.getYUNZHOU());
        }
        yfnl = (EditText) findViewById(R.id.yfnl);
        if (obj != null && !StringUtils.isEmpty(obj.getYFNL())) {
            yfnl.setText(obj.getYFNL());
        }
        zfxm = (EditText) findViewById(R.id.zfxm);
        if (obj != null && !StringUtils.isEmpty(obj.getZFXM())) {
            zfxm.setText(obj.getZFXM());
        }
        zfnl = (EditText) findViewById(R.id.zfnl);
        if (obj != null && !StringUtils.isEmpty(obj.getZFNL())) {
            zfnl.setText(obj.getZFNL());
        }

        ydfm = (EditText) findViewById(R.id.ydfm);
        if (obj != null && !StringUtils.isEmpty(obj.getCHANCI_YD())) {
            ydfm.setText(obj.getCHANCI_YD());
        }
        pgc = (EditText) findViewById(R.id.pgc);
        if (obj != null && !StringUtils.isEmpty(obj.getCHANCI_PG())) {
            pgc.setText(obj.getCHANCI_PG());
        }
        mcyj = (CheckBox) findViewById(R.id.mcyj);
        mcyjdes = (EditText) findViewById(R.id.mcyjdes);
        if (obj != null && !StringUtils.isEmpty(obj.getMCYJ())) {
            mcyjdes.setText(obj.getMCYJ());
            if (obj.getMCYJ().equals("不详")) {
                mcyj.setChecked(true);
            } else {
                mcyj.setChecked(true);
            }
        }
        mcyj.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() {
            @Override
            public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {
                if (isChecked) {
                    obj.setMCYJ("不详");
                } else {
                    obj.setMCYJ("");
                }
            }
        });
        ycq = (EditText) findViewById(R.id.ycq);
        if (obj != null && !StringUtils.isEmpty(obj.getYCQ())) {
            ycq.setText(obj.getYCQ());
        }
        jwsqt = (EditText) findViewById(R.id.jws_qt);
        if (obj != null && !StringUtils.isEmpty(obj.getJWSQT())) {
            jwsqt.setText(obj.getJWSQT());
        }
        jws = (MultiLineChooseLayout) findViewById(R.id.jws);
        jwsdata.add("无");
        jwsdata.add("心脏病");
        jwsdata.add("肾脏疾病");
        jwsdata.add("肝脏疾病");
        jwsdata.add("高血压");
        jwsdata.add("贫血");
        jwsdata.add("糖尿病");
        jwsdata.add("其他");
        jws.setList(jwsdata);
        if (obj != null && !StringUtils.isEmpty(obj.getJWS())) {
            if (obj.getJWS().contains("1"))
                jws.setIndexItemSelected(0);
            if (obj.getJWS().contains("2"))
                jws.setIndexItemSelected(1);
            if (obj.getJWS().contains("3"))
                jws.setIndexItemSelected(2);
            if (obj.getJWS().contains("4"))
                jws.setIndexItemSelected(3);
            if (obj.getJWS().contains("5"))
                jws.setIndexItemSelected(4);
            if (obj.getJWS().contains("6"))
                jws.setIndexItemSelected(5);
            if (obj.getJWS().contains("7"))
                jws.setIndexItemSelected(6);
            if (obj.getJWS().contains("8"))
                jws.setIndexItemSelected(7);
        }

        jzs = (MultiLineChooseLayout) findViewById(R.id.jzs);
        jzsdata.add("无");
        jzsdata.add("遗传性疾病史");
        jzsdata.add("精神疾病史");
        jzsdata.add("其他");
        jzs.setList(jzsdata);
        if (obj != null && !StringUtils.isEmpty(obj.getJZS())) {
            if (obj.getJZS().contains("1"))
                jzs.setIndexItemSelected(0);
            if (obj.getJZS().contains("2"))
                jzs.setIndexItemSelected(1);
            if (obj.getJZS().contains("3"))
                jzs.setIndexItemSelected(2);
            if (obj.getJZS().contains("4"))
                jzs.setIndexItemSelected(3);
        }
        jzsqt = (EditText) findViewById(R.id.jzs_qt);
        if (obj != null && !StringUtils.isEmpty(obj.getJZSQT())) {
            jzsqt.setText(obj.getJZSQT());
        }
        grsqt = (EditText) findViewById(R.id.grs_qt);
        if (obj != null && !StringUtils.isEmpty(obj.getGRSQT())) {
            grsqt.setText(obj.getGRSQT());
        }
        grs = (MultiLineChooseLayout) findViewById(R.id.grs);
        grsdata.add("无");
        grsdata.add("遗传性疾病史");
        grsdata.add("精神疾病史");
        grsdata.add("其他");
        grs.setList(grsdata);
        if (obj != null && !StringUtils.isEmpty(obj.getGRS())) {
            if (obj.getGRS().contains("1"))
                grs.setIndexItemSelected(0);
            if (obj.getGRS().contains("2"))
                grs.setIndexItemSelected(1);
            if (obj.getGRS().contains("3"))
                grs.setIndexItemSelected(2);
            if (obj.getGRS().contains("4"))
                grs.setIndexItemSelected(3);
        }
        //手术、外伤、输血
        fksss = (RadioGroup) findViewById(R.id.fksss);
        if (obj != null && !StringUtils.isEmpty(obj.getFKSSS())) {
            switch (Integer.parseInt(obj.getFKSSS())) {
                case 1:
                    fksss.check(R.id.fksss1);
                    break;
                case 2:
                    fksss.check(R.id.fksss2);
                    break;
            }
        }
        fksss.setOnCheckedChangeListener(new RadioGroup.OnCheckedChangeListener() {
            @Override
            public void onCheckedChanged(RadioGroup group, int checkedId) {
                if (checkedId == R.id.fksss1)
                    obj.setFKSSS("1");
                else
                    obj.setFKSSS("2");
            }
        });
        fksssdes = (EditText) findViewById(R.id.fksssdes);
        if (obj != null && !StringUtils.isEmpty(obj.getFKSSSQT())) {
            fksssdes.setText(obj.getFKSSSQT());
        }
        zrlc = (EditText) findViewById(R.id.zrlc);
        if (obj != null && !StringUtils.isEmpty(obj.getYCSLC())) {
            zrlc.setText(obj.getYCSLC());
        }
        rglc = (EditText) findViewById(R.id.rglc);
        if (obj != null && !StringUtils.isEmpty(obj.getYCSLCRG())) {
            rglc.setText(obj.getYCSLCRG());
        }
        st = (EditText) findViewById(R.id.st);
        if (obj != null && !StringUtils.isEmpty(obj.getYCSST())) {
            st.setText(obj.getYCSST());
        }
        sc = (EditText) findViewById(R.id.sc);
        if (obj != null && !StringUtils.isEmpty(obj.getYCSSC())) {
            sc.setText(obj.getYCSSC());
        }
        xsesw = (EditText) findViewById(R.id.xsesw);
        if (obj != null && !StringUtils.isEmpty(obj.getYCSXSESW())) {
            xsesw.setText(obj.getYCSXSESW());
        }
        cseqx = (EditText) findViewById(R.id.cseqx);
        if (obj != null && !StringUtils.isEmpty(obj.getYCSCSQXE())) {
            cseqx.setText(obj.getYCSCSQXE());
        }

        sg = (EditText) findViewById(R.id.sg);
        if (obj != null && !StringUtils.isEmpty(obj.getSHENGAO())) {
            sg.setText(obj.getSHENGAO());
        }
        tz = (EditText) findViewById(R.id.tz);
        if (obj != null && !StringUtils.isEmpty(obj.getTIZHONG())) {
            tz.setText(obj.getTIZHONG());
        }
        tzl = (EditText) findViewById(R.id.bmi);
        if (obj != null && !StringUtils.isEmpty(obj.getBMI())) {
            tzl.setText(obj.getBMI());
        }
        xy1 = (EditText) findViewById(R.id.xy1);
        if (obj != null && !StringUtils.isEmpty(obj.getXUEYA1())) {
            xy1.setText(obj.getXUEYA1());
        }
        xy2 = (EditText) findViewById(R.id.xy2);
        if (obj != null && !StringUtils.isEmpty(obj.getXUEYA2())) {
            xy2.setText(obj.getXUEYA2());
        }
        xz = (RadioGroup) findViewById(R.id.xz);
        if (obj != null && !StringUtils.isEmpty(obj.getXZYC())) {
            switch (Integer.parseInt(obj.getXZYC())) {
                case 1:
                    xz.check(R.id.xz_wu);
                    break;
                case 2:
                    xz.check(R.id.xz_you);
                    break;
            }
        }
        xz.setOnCheckedChangeListener(new RadioGroup.OnCheckedChangeListener() {
            @Override
            public void onCheckedChanged(RadioGroup group, int checkedId) {
                if (checkedId == R.id.xz_wu) {
                    obj.setXZYC("1");
                    xzqt.setEnabled(false);
                } else {
                    obj.setXZYC("2");
                    xzqt.setEnabled(true);
                }
            }
        });
        xzqt = (EditText) findViewById(R.id.xz_qt);
        if (obj != null && !StringUtils.isEmpty(obj.getXINZANG())) {
            xzqt.setText(obj.getXINZANG());
        }

        fb = (RadioGroup) findViewById(R.id.fb);
        if (obj != null && !StringUtils.isEmpty(obj.getFBYC())) {
            switch (Integer.parseInt(obj.getFBYC())) {
                case 1:
                    fb.check(R.id.fb_wu);
                    break;
                case 2:
                    fb.check(R.id.fb_you);
                    break;
            }
        }
        fb.setOnCheckedChangeListener(new RadioGroup.OnCheckedChangeListener() {
            @Override
            public void onCheckedChanged(RadioGroup group, int checkedId) {
                if (checkedId == R.id.fb_wu) {
                    obj.setFEIBU("1");
                    fbqt.setEnabled(false);
                } else {
                    fbqt.setEnabled(true);
                    obj.setFEIBU("2");
                }
            }
        });
        fbqt = (EditText) findViewById(R.id.fb_yc);
        if (obj != null && !StringUtils.isEmpty(obj.getFEIBU())) {
            fbqt.setText(obj.getFEIBU());
        }


        wy = (RadioGroup) findViewById(R.id.wy);
        if (obj != null && !StringUtils.isEmpty(obj.getWYYC())) {
            switch (Integer.parseInt(obj.getWYYC())) {
                case 1:
                    wy.check(R.id.wy_wu);
                    break;
                case 2:
                    wy.check(R.id.wy_you);
                    break;
            }
        }
        wy.setOnCheckedChangeListener(new RadioGroup.OnCheckedChangeListener() {
            @Override
            public void onCheckedChanged(RadioGroup group, int checkedId) {
                if (checkedId == R.id.wy_wu) {
                    obj.setWAIYIN("1");
                    wyqt.setEnabled(false);
                } else {
                    wyqt.setEnabled(true);
                    obj.setWAIYIN("2");
                }
            }
        });
        wyqt = (EditText) findViewById(R.id.wy_yc);
        if (obj != null && !StringUtils.isEmpty(obj.getWAIYIN())) {
            wyqt.setText(obj.getWAIYIN());
        }

        yd = (RadioGroup) findViewById(R.id.yd);
        if (obj != null && !StringUtils.isEmpty(obj.getYDYC())) {
            switch (Integer.parseInt(obj.getYDYC())) {
                case 1:
                    yd.check(R.id.yd_wu);
                    break;
                case 2:
                    yd.check(R.id.yd_you);
                    break;
            }
        }
        yd.setOnCheckedChangeListener(new RadioGroup.OnCheckedChangeListener() {
            @Override
            public void onCheckedChanged(RadioGroup group, int checkedId) {
                if (checkedId == R.id.yd_wu) {
                    ydqt.setEnabled(false);
                    obj.setYINDAO("1");
                } else {
                    ydqt.setEnabled(true);
                    obj.setYINDAO("2");
                }
            }
        });
        ydqt = (EditText) findViewById(R.id.yd_yc);
        if (obj != null && !StringUtils.isEmpty(obj.getYINDAO())) {
            ydqt.setText(obj.getYINDAO());
        }


        gj = (RadioGroup) findViewById(R.id.gj);
        if (obj != null && !StringUtils.isEmpty(obj.getGJYC())) {
            switch (Integer.parseInt(obj.getGJYC())) {
                case 1:
                    gj.check(R.id.gj_wu);
                    break;
                case 2:
                    gj.check(R.id.gj_you);
                    break;
            }
        }
        gj.setOnCheckedChangeListener(new RadioGroup.OnCheckedChangeListener() {
            @Override
            public void onCheckedChanged(RadioGroup group, int checkedId) {
                if (checkedId == R.id.gj_wu) {
                    obj.setGONGJING("1");
                    gj.setEnabled(false);
                } else {
                    obj.setGONGJING("2");
                    gj.setEnabled(true);
                }
            }
        });


        gjqt = (EditText) findViewById(R.id.gj_yc);
        if (obj != null && !StringUtils.isEmpty(obj.getGONGJING())) {
            gjqt.setText(obj.getGONGJING());
        }


        zg = (RadioGroup) findViewById(R.id.zg);
        if (obj != null && !StringUtils.isEmpty(obj.getZGYC())) {
            switch (Integer.parseInt(obj.getZGYC())) {
                case 1:
                    zg.check(R.id.zg_wu);
                    break;
                case 2:
                    zg.check(R.id.zg_you);
                    break;
            }
        }
        zgqt = (EditText) findViewById(R.id.zg_yc);
        if (obj != null && !StringUtils.isEmpty(obj.getZIGONG())) {
            zgqt.setText(obj.getZIGONG());
        }
        fj = (RadioGroup) findViewById(R.id.fj);
        if (obj != null && !StringUtils.isEmpty(obj.getFJYC())) {
            switch (Integer.parseInt(obj.getFJYC())) {
                case 1:
                    fj.check(R.id.fj_wu);
                    break;
                case 2:
                    fj.check(R.id.fj_you);
                    break;
            }
        }
        zg.setOnCheckedChangeListener(new RadioGroup.OnCheckedChangeListener() {
            @Override
            public void onCheckedChanged(RadioGroup group, int checkedId) {
                if (checkedId == R.id.zg_wu) {
                    obj.setZIGONG("1");
                    zgqt.setEnabled(false);
                } else {
                    zgqt.setEnabled(true);
                    obj.setZIGONG("2");
                }
            }
        });
        fj.setOnCheckedChangeListener(new RadioGroup.OnCheckedChangeListener() {
            @Override
            public void onCheckedChanged(RadioGroup group, int checkedId) {
                if (checkedId == R.id.fj_wu) {
                    obj.setFUJIAN("1");
                    fjqt.setEnabled(false);
                } else {
                    fjqt.setEnabled(true);
                    obj.setFUJIAN("2");
                }
            }
        });
        fjqt = (EditText) findViewById(R.id.fj_yc);
        if (obj != null && !StringUtils.isEmpty(obj.getFUJIAN())) {
            fjqt.setText(obj.getFUJIAN());
        }
        xhdbz = (EditText) findViewById(R.id.xhdbz);
        if (obj != null && !StringUtils.isEmpty(obj.getXHDBZ())) {
            xhdbz.setText(obj.getXHDBZ());
        }
        bxbjsz = (EditText) findViewById(R.id.bxbjsz);
        if (obj != null && !StringUtils.isEmpty(obj.getBXBJSZ())) {
            bxbjsz.setText(obj.getBXBJSZ());
        }
        xxbjsz = (EditText) findViewById(R.id.xxbjsz);
        if (obj != null && !StringUtils.isEmpty(obj.getXXBJSZ())) {
            xxbjsz.setText(obj.getXXBJSZ());
        }
        xcgqt = (EditText) findViewById(R.id.xcg_qt);
        if (obj != null && !StringUtils.isEmpty(obj.getXCGQT())) {
            xcgqt.setText(obj.getXCGQT());
        }
        ndb = (EditText) findViewById(R.id.ndb);
        if (obj != null && !StringUtils.isEmpty(obj.getNDB())) {
            ndb.setText(obj.getNDB());
        }
        nt = (EditText) findViewById(R.id.nt);
        if (obj != null && !StringUtils.isEmpty(obj.getNT())) {
            nt.setText(obj.getNT());
        }
        ndt = (EditText) findViewById(R.id.ntt);
        if (obj != null && !StringUtils.isEmpty(obj.getNTT())) {
            ndt.setText(obj.getNTT());
        }
        nqx = (EditText) findViewById(R.id.nqx);
        if (obj != null && !StringUtils.isEmpty(obj.getNQX())) {
            nqx.setText(obj.getNQX());
        }
        ncgqt = (EditText) findViewById(R.id.ncg_qt);
        if (obj != null && !StringUtils.isEmpty(obj.getNCGQT())) {
            ncgqt.setText(obj.getNCGQT());
        }
        //abo血型
        //手术、外伤、输血
        xx = (RadioGroup) findViewById(R.id.xx);
        if (obj != null && !StringUtils.isEmpty(obj.getXX())) {
            switch (Integer.parseInt(obj.getXX())) {
                case 1:
                    xx.check(R.id.xx1);
                    break;
                case 2:
                    xx.check(R.id.xx2);
                    break;
                case 3:
                    xx.check(R.id.xx3);
                    break;
                case 4:
                    xx.check(R.id.xx4);
                    break;

            }
        }
        xx.setOnCheckedChangeListener(new RadioGroup.OnCheckedChangeListener() {
            @Override
            public void onCheckedChanged(RadioGroup group, int checkedId) {
                if (checkedId == R.id.xx1)
                    obj.setXX("1");
                else if (checkedId == R.id.xx2)
                    obj.setXX("2");
                else if (checkedId == R.id.xx3)
                    obj.setXX("3");
                else if (checkedId == R.id.xx4)
                    obj.setXX("4");
            }
        });
        //RH
        xxrh = (RadioGroup) findViewById(R.id.rh);
        if (obj != null && !StringUtils.isEmpty(obj.getRH())) {
            switch (Integer.parseInt(obj.getRH())) {
                case 1:
                    xxrh.check(R.id.rh1);
                    break;
                case 2:
                    xxrh.check(R.id.rh2);
                    break;
            }
        }
        xxrh.setOnCheckedChangeListener(new RadioGroup.OnCheckedChangeListener() {
            @Override
            public void onCheckedChanged(RadioGroup group, int checkedId) {
                if (checkedId == R.id.rh1)
                    obj.setXX("2");
                else if (checkedId == R.id.rh2)
                    obj.setXX("3");
            }
        });

        xt = (EditText) findViewById(R.id.xt);
        if (obj != null && !StringUtils.isEmpty(obj.getXT())) {
            xt.setText(obj.getXT());
        }
        xqgbzam = (EditText) findViewById(R.id.xqgnzam);
        if (obj != null && !StringUtils.isEmpty(obj.getXQGBZAM())) {
            xqgbzam.setText(obj.getXQGBZAM());
        }
        xqgczam = (EditText) findViewById(R.id.xqgczam);
        if (obj != null && !StringUtils.isEmpty(obj.getXQGCZAM())) {
            xqgczam.setText(obj.getXQGCZAM());
        }

        bdb = (EditText) findViewById(R.id.bdb);
        if (obj != null && !StringUtils.isEmpty(obj.getBDB())) {
            bdb.setText(obj.getBDB());
        }
        zdhs = (EditText) findViewById(R.id.zdhs);
        if (obj != null && !StringUtils.isEmpty(obj.getZDHS())) {
            zdhs.setText(obj.getZDHS());
        }
        jhdhs = (EditText) findViewById(R.id.jhdhs);
        if (obj != null && !StringUtils.isEmpty(obj.getJHDHS())) {
            jhdhs.setText(obj.getJHDHS());
        }
        xqjg = (EditText) findViewById(R.id.xqjg);
        if (obj != null && !StringUtils.isEmpty(obj.getXQJG())) {
            xqjg.setText(obj.getXQJG());
        }
        xns = (EditText) findViewById(R.id.xns);
        if (obj != null && !StringUtils.isEmpty(obj.getXNSD())) {
            xns.setText(obj.getXNSD());
        }

        ydfmw = (MultiLineChooseLayout) findViewById(R.id.ydfmw);
        ydfmwdata.add("未见异常");
        ydfmwdata.add("滴虫");
        ydfmwdata.add("假丝酵母菌");
        ydfmwdata.add("其他");
        ydfmw.setList(ydfmwdata);
        if (obj != null && !StringUtils.isEmpty(obj.getYDFMW())) {
            if (obj.getYDFMW().contains("1"))
                ydfmw.setIndexItemSelected(0);
            if (obj.getYDFMW().contains("2"))
                ydfmw.setIndexItemSelected(1);
            if (obj.getYDFMW().contains("3"))
                ydfmw.setIndexItemSelected(2);
            if (obj.getYDFMW().contains("4"))
                ydfmw.setIndexItemSelected(3);
        }

        ydfmwqt = (EditText) findViewById(R.id.ydfmw_qt);
        if (obj != null && !StringUtils.isEmpty(obj.getYDFMWQT())) {
            ydfmwqt.setText(obj.getYDFMWQT());
        }

        ydqjd = (MultiLineChooseLayout) findViewById(R.id.ydqjd);
        ydqjddata.add("Ⅰ度");
        ydqjddata.add("Ⅱ度");
        ydqjddata.add("Ⅲ度");
        ydqjddata.add("Ⅳ度 ");
        ydqjd.setList(ydqjddata);
        if (obj != null && !StringUtils.isEmpty(obj.getYDFMW())) {
            if (obj.getYDFMW().contains("1"))
                ydqjd.setIndexItemSelected(0);
            if (obj.getYDFMW().contains("2"))
                ydqjd.setIndexItemSelected(1);
            if (obj.getYDFMW().contains("3"))
                ydqjd.setIndexItemSelected(2);
            if (obj.getYDFMW().contains("4"))
                ydqjd.setIndexItemSelected(3);
        }
        yxggybmky = (EditText) findViewById(R.id.yxgybmky);
        if (obj != null && !StringUtils.isEmpty(obj.getYXGYBMKY())) {
            yxggybmky.setText(obj.getYXGYBMKY());
        }
        yxgybmkt = (EditText) findViewById(R.id.yxgybmkt);
        if (obj != null && !StringUtils.isEmpty(obj.getYXGYBMKT())) {
            yxgybmkt.setText(obj.getYXGYBMKT());
        }
        yxgyeky = (EditText) findViewById(R.id.yxgyeky);
        if (obj != null && !StringUtils.isEmpty(obj.getYXGYEKY())) {
            yxgyeky.setText(obj.getYXGYEKY());
        }
        yxgyekt = (EditText) findViewById(R.id.yxgyekt);
        if (obj != null && !StringUtils.isEmpty(obj.getYXGYEKT())) {
            yxgyekt.setText(obj.getYXGYEKT());
        }
        yxgyhxkt = (EditText) findViewById(R.id.yxgyhxkt);
        if (obj != null && !StringUtils.isEmpty(obj.getYXGYHXKT())) {
            yxgyhxkt.setText(obj.getYXGYHXKT());
        }

        mdxqxsy = (RadioGroup) findViewById(R.id.mdxqxsy);
        if (obj != null && !StringUtils.isEmpty(obj.getMDXQXSY())) {
            switch (Integer.parseInt(obj.getMDXQXSY())) {
                case 1:
                    mdxqxsy.check(R.id.mdxqxsy_yin);
                    break;
                case 2:
                    mdxqxsy.check(R.id.mdxqxsy_yang);
                    break;
            }
        }
        mdxqxsy.setOnCheckedChangeListener(new RadioGroup.OnCheckedChangeListener() {
            @Override
            public void onCheckedChanged(RadioGroup group, int checkedId) {
                if (checkedId == R.id.mdxqxsy_yin)
                    obj.setMDXQXSY("1");
                else
                    obj.setMDXQXSY("2");
            }
        });
        hivktcy = (RadioGroup) findViewById(R.id.hivktjc);
        if (obj != null && !StringUtils.isEmpty(obj.getMDXQXSY())) {
            switch (Integer.parseInt(obj.getMDXQXSY())) {
                case 1:
                    hivktcy.check(R.id.hivktjc_yin);
                    break;
                case 2:
                    hivktcy.check(R.id.hivktjc_yang);
                    break;
            }
        }
        hivktcy.setOnCheckedChangeListener(new RadioGroup.OnCheckedChangeListener() {
            @Override
            public void onCheckedChanged(RadioGroup group, int checkedId) {
                if (checkedId == R.id.hivktjc_yin)
                    obj.setHIVKTJC("1");
                else
                    obj.setHIVKTJC("2");
            }
        });
        bc = (EditText) findViewById(R.id.bc);
        if (obj != null && !StringUtils.isEmpty(obj.getBCHAO())) {
            bc.setText(obj.getBCHAO());
        }
        yxgywxqt = (EditText) findViewById(R.id.yxgywxqt);///////////////////////////////////////////////////////////////////////暂无

        ztpg = (RadioGroup) findViewById(R.id.ztpg);
        if (obj != null && !StringUtils.isEmpty(obj.getZTPG())) {
            if (obj.getZTPG().equals("未见异常")) {
                ztpg.check(R.id.ztpg_wu);
            } else {
                ztpg.check(R.id.ztpg_you);
            }
        }
        ztpg.setOnCheckedChangeListener(new RadioGroup.OnCheckedChangeListener() {
            @Override
            public void onCheckedChanged(RadioGroup group, int checkedId) {
                if (checkedId == R.id.ztpg_wu) {
                    obj.setZTPG("未见异常");
                    ztpgyc.setEnabled(false);
                } else {
                    ztpgyc.setEnabled(true);
                    obj.setZTPG("异常");
                }
            }
        });
        ztpgyc = (EditText) findViewById(R.id.ztpg_yc);////////////////////////////////////////////////////////////////////////////////暂无

        bjzd = (MultiLineChooseLayout) findViewById(R.id.bjzd);
        bjzddata.add("生活方式");
        bjzddata.add("心理");
        bjzddata.add("营养");
        bjzddata.add("避免致畸因素和疾病对胚胎的不良影响 ");
        bjzddata.add("产前筛查宣传告知");
        bjzddata.add("其他");
        bjzd.setList(bjzddata);
        if (obj != null && !StringUtils.isEmpty(obj.getBJZD())) {
            if (obj.getBJZD().contains("1"))
                bjzd.setIndexItemSelected(0);
            if (obj.getBJZD().contains("2"))
                bjzd.setIndexItemSelected(1);
            if (obj.getBJZD().contains("3"))
                bjzd.setIndexItemSelected(2);
            if (obj.getBJZD().contains("4"))
                bjzd.setIndexItemSelected(3);
            if (obj.getBJZD().contains("5"))
                bjzd.setIndexItemSelected(4);
            if (obj.getBJZD().contains("6"))
                bjzd.setIndexItemSelected(5);
        }

        bjzdqt = (EditText) findViewById(R.id.bjzd_qt);
        if (obj != null && !StringUtils.isEmpty(obj.getBJZDQT())) {
            bjzdqt.setText(obj.getBJZDQT());
        }

        jcqk = (RadioGroup) findViewById(R.id.jcqk);
        if (obj != null && !StringUtils.isEmpty(obj.getJCQK())) {
            switch (Integer.parseInt(obj.getJCQK())) {
                case 1:
                    jcqk.check(R.id.jcqk1);
                    break;
                case 2:
                    jcqk.check(R.id.jcqk2);
                    break;
            }
        }
        jcqk.setOnCheckedChangeListener(new RadioGroup.OnCheckedChangeListener() {
            @Override
            public void onCheckedChanged(RadioGroup group, int checkedId) {
                if (checkedId == R.id.jcqk1)
                    obj.setJCQK("1");
                else
                    obj.setJCQK("2");
            }
        });

    }

    @Override
    protected void initData() {

    }

    @Override
    protected void initListener() {

    }

    /////////getobject
    public void getObject() {
        RequestParams ps = new RequestParams();
        ps.add("token", SharedPreferencesUtils.getParam(con, "token", "").toString());
        ps.add("type", "2");
        ps.add("CARDNUM", j.getCARDNUM());
        ps.add("yunci", yunci.getText().toString());
        UserClient.get(HttpUrl.GetYcf1Grjbxx, ps, new AsyncHttpResponseHandler() {
            @Override
            public void onSuccess(int statusCode, Header[] headers, byte[] response) {
                String content = new String(response);
                RetMsg ret = JSON.parseObject(content, RetMsg.class);
                if (ret.getCode().equals("200")) {
                    if (StringUtils.isEmpty(ret.getOtherParams())) {//other是空的
                        JSONObject j = JSON.parseObject(ret.getRd());
                        obj = new YcfDyccqjc();
                        obj.setJKDAH(j.getString("JKDAH"));
                        obj.setMCYJ(j.getString("MCYJ"));
                        obj.setXINGMING(j.getString("XINGMING"));
                        obj.setCARDNUM(j.getString("CARDNUM"));
                        mcyjdes.setText(j.getString("MCYJ"));
                        JKDAH = j.getString("JKDAH");
                        xm.setText(j.getString("XINGMING"));
                        isadd = true;
                    } else {
                    /*    obj = JSON.parseObject(ret.getRd(), YcfDyccqjc.class);
                        isadd = false;
                        init();*/
                    }
                }else{
                    SweetAlertDialogUtil.ErrorDialogNoFinish(con, "错误提示", ret.getInfo(), "确定");
                }

            }

            @Override
            public void onFinish() {
                super.onFinish();
            }

            @Override
            public void onFailure(int statusCode, Header[] headers, byte[] errorResponse, Throwable e) {

                isadd = true;
                obj = new YcfDyccqjc();
            }
        });
    }

    class CustomerListener implements View.OnClickListener {
        @Override
        public void onClick(View v) {
            if(obj != null && StringUtils.isEmpty(obj.getJKDAH())) {
                SweetAlertDialogUtil.WarningDialog(con, "提示", "选择居民用户后才能现场拍照");
            }else {
                Intent intent = new Intent(con, CameraChoose.class)
                        .putExtra("type", "edit")
                        .putExtra("cardnum", obj.getCARDNUM())
                        .putExtra("tabId", null==obj.getSFJLH()||"".equals(obj.getSFJLH()) ? "noid" : obj.getSFJLH())
                        .putExtra("tabType", "ycfdyccqsf")
                        .putExtra("class", "ycf_1.class");
                startActivityForResult(intent, 119);
            }
        }
    }
}
